import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * expertService.js - 工作台系统消息卡片 service
 * @date: 2019-08-28
 */
import request from 'utils/request';
import { getCurrentOrganizationId, isTenantRoleLevel } from 'utils/utils';
import { CPAAS_MSG } from 'utils/config';
var organizationId = getCurrentOrganizationId();

function message() {
  return isTenantRoleLevel() ? "".concat(organizationId, "/") : '';
}
/**
 *
 * 系统消息查询
 * @param {Object} params 查询参数
 * @export
 * @returns
 */


export function queryUserMessage(_x) {
  return _queryUserMessage.apply(this, arguments);
}
/**
 * 查询公告列表数据
 * @param {Object} params - 查询参数
 */

function _queryUserMessage() {
  _queryUserMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_MSG, "/v1/").concat(organizationId, "/messages/user"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryUserMessage.apply(this, arguments);
}

export function queryAnnouncement(_x2) {
  return _queryAnnouncement.apply(this, arguments);
}
/**
 *改变消息为已读
 *
 * @export
 * @param {*} params
 * @returns
 */

function _queryAnnouncement() {
  _queryAnnouncement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_MSG, "/v1/").concat(message(), "notices"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _queryAnnouncement.apply(this, arguments);
}

export function changeRead(_x3) {
  return _changeRead.apply(this, arguments);
}

function _changeRead() {
  _changeRead = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(params) {
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            return _context3.abrupt("return", request("".concat(CPAAS_MSG, "/v1/").concat(organizationId, "/messages/user/read-flag"), {
              method: 'POST',
              query: params
            }));

          case 1:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _changeRead.apply(this, arguments);
}